 
	
		**********************************************************
		** File: HTI_v1_errata.do								**
		** Paper: Human Trafficking Indicators: A New Dataset	**
		** Author: Richard Frank								**
		** Date: July 11, 2021									**
		** Task: Cleaning HTI errata for v1	**
		**********************************************************
	 
		clear all
		set seed 1234
		version 16.1

		use " HTI 00-17.dta", clear

		drop Country
		  
		* 1. Fixing child sexual exploitation and child soldiers merging errors **
		* the summary statistics for these variables in Table B1 reflect the 
		* changes below
		 
		browse country ccode year c*
		 
		* source *
		clonevar cpsource1=cpsource
		replace cpsource1=cssource if cpsource1==. & cssource~=.
		replace cssource=csource if csource~=. & cpsource==.
		 
		* transit
		clonevar cptransit1=cptransit
		replace cptransit1=cstransit if cptransit1==. & cstransit~=.
		replace cstransit=ctransit if ctransit~=. & cptransit==.
		
		* Destination
		clonevar cpdest1=cpdest
		replace cpdest1=csdest if cpdest1==. & csdest~=.
		replace csdest=cdest if cdest~=. & cpdest==.
				
		* Internal
		clonevar cpinternal1=cpinternal
		replace cpinternal1=csinternal if cpinternal1==. & csinternal~=.
		replace csinternal=cinternal if cinternal~=. & cpinternal==.
				
		drop cpsource cptransit cpdest cpinternal csource ctransit cdest cinternal
		rename cpsource1 cpsource 
		tab cpsource
		tab cssource
		rename cptransit1 cptransit
		tab cptransit
		tab cstransit
		rename cpdest1  cpdest
		tab cpdest
		tab csdest
		rename cpinternal1	cpinternal
		tab cpinternal
		tab csinternal
	  
		** 2. dropping observations that do not have large enough populations for 
		** inclusion or are not autonomous areas
	  
		drop if ccode<0 
	  
		** 3. correcting country names **
	 
		replace country="Korea, South" if ccode==732
		replace ccode=732 if ccode==730
		replace country="Korea, North" if ccode==731
		replace country="Bahamas, The" if country=="Bahamas"
		replace country="Solomon Islands" if country=="Solomon Island"
		replace country="Serbia" if country=="Serbia "
		replace country="Kyrgyzstan" if country=="Kyrgyz Republic"
		replace country="Gambia, The" if country=="Gambia"
		replace country="Equatorial Guinea" if country=="Equatorial Quinea"
		replace country="Cote d'Ivoire" if country=="Cote D'Ivoire"
		replace country="Eswatini" if country=="Swaziland"
		replace country="Congo, Republic" if country=="Republic of the Congo"
		replace country="Myanmar" if country=="Burma"
		codebook ccode country
		tab country
 
		** 4. Fixing incorrect merge with protectprogress
		browse country ccode year progress preventprogress
		codebook preventprogress if progress~=. 
		replace preventprogress=progress if progress~=. & preventprogress==. 
		drop progress
		  
		** 5. Filling in treaty info for 2014-2017 data **
		** The 2017 version of the HTI data includes information about the signing
		** and ratifying of many more relevant international treaties than the 
		** Palermo Protocol. Thus I delete the old protocol variable and include a 
		** number of variables for signature or ratification dates.
		 
		drop protocol	 
		sort ccode year
		by ccode: replace UNP_sign=UNP_sign[_n-1] if UNP_sign=="" & UNP_sign[_n-1] ~="" 
		by ccode: replace UNP_rat=UNP_rat[_n-1] if UNP_rat=="" & UNP_rat[_n-1] ~="" 
		by ccode: replace ILO182=ILO182[_n-1] if ILO182==. & ILO182[_n-1] ~=. 
		by ccode: replace ILO29=ILO29[_n-1] if ILO29==. & ILO29[_n-1] ~=. 
		by ccode: replace ILO105=ILO105[_n-1] if ILO105==. & ILO105[_n-1] ~=.  	 	 	 
		by ccode: replace CEDAW_sign=CEDAW_sign[_n-1] if CEDAW_sign=="" & CEDAW_sign[_n-1] ~="" 	  
		by ccode: replace CEDAW_rat=CEDAW_rat[_n-1] if CEDAW_rat=="" & CEDAW_rat[_n-1] ~="" 	  
		by ccode: replace UNCRC_sign=UNCRC_sign[_n-1] if UNCRC_sign=="" & UNCRC_sign[_n-1] ~=""   
		by ccode: replace UNCRC_rat=UNCRC_rat[_n-1] if UNCRC_rat=="" & UNCRC_rat[_n-1] ~="" 	  
		by ccode: replace conflict_sign=conflict_sign[_n-1] if conflict_sign=="" & conflict_sign[_n-1] ~="" 		  
		by ccode: replace conflict_rat=conflict_rat[_n-1] if conflict_rat=="" & conflict_rat[_n-1] ~="" 		 

		** 6. Ordering variables **
		  
		browse
		order country ccode year  tier  ///
		TRAFFICKING_FLOWS source source_order transit transit_order ///
		destination destination_order internal ///
		TRAFFICKING_TYPES psource ptransit pdest ///
		pinternal lsource ltransit ldest linternal dsource dtransit ddest dinternal ///
		dssource dstransit dsdest dsinternal cpsource cptransit cpdest cpinternal ///
		clsource cltransit cldest clinternal cssource ///
		cstransit csdest csinternal ///
		PROSECUTION domesticlaws enforcement ///
		convictinfo prosnum minstand efforts ///
		PROTECTION protectprogress victimid  victimservices victimpunish ///
		PREVENTION preventprogress ///
		INTERNATIONAL_LAWS  
	 
		note: "Replication dataset for Human Trafficking Indicators: A New Dataset"
		datasignature
		* 2663:67(87133):219555760:956659270
		note: `r(datasignature)'
	 
		save "/HTI_v1.dta", replace
